var ua=Object.defineProperty;var Tr=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var da=(e,t)=>()=>(e&&(t=e(e=0)),t);var fa=(e,t)=>{for(var r in t)ua(e,r,{get:t[r],enumerable:!0})};var Ro={};fa(Ro,{preCache:()=>zl,snapdom:()=>Q});function ha(e){if(e===!0)return"soft";if(e===!1)return"disabled";if(typeof e=="string"){let t=e.toLowerCase().trim();if(t==="auto")return"auto";if(t==="full")return"full";if(t==="soft"||t==="disabled")return t}return"soft"}function Jn(e="soft"){switch(x.session.__counterEpoch=(x.session.__counterEpoch||0)+1,e){case"auto":{x.session.styleMap=new Map,x.session.nodeMap=new Map;return}case"soft":{x.session.styleMap=new Map,x.session.nodeMap=new Map,x.session.styleCache=new WeakMap;return}case"full":return;case"disabled":{x.session.styleMap=new Map,x.session.nodeMap=new Map,x.session.styleCache=new WeakMap,x.computedStyle=new WeakMap,x.baseStyle=new pe(50),x.defaultStyle=new pe(30),x.image=new pe(100),x.background=new pe(100),x.resource=new pe(150),x.font=new Set;return}default:{x.session.styleMap=new Map,x.session.nodeMap=new Map,x.session.styleCache=new WeakMap;return}}}function Gr(e){let t=e.match(/url\((['"]?)(.*?)(\1)\)/);if(!t)return null;let r=t[2].trim();return r.startsWith("#")?null:r}function ga(e){if(!e||e==="none")return"";let t=e.replace(/translate[XY]?\([^)]*\)/g,"");return t=t.replace(/matrix\(([^)]+)\)/g,(r,n)=>{let o=n.split(",").map(i=>i.trim());return o.length!==6?`matrix(${n})`:(o[4]="0",o[5]="0",`matrix(${o.join(", ")})`)}),t=t.replace(/matrix3d\(([^)]+)\)/g,(r,n)=>{let o=n.split(",").map(i=>i.trim());return o.length!==16?`matrix3d(${n})`:(o[12]="0",o[13]="0",`matrix3d(${o.join(", ")})`)}),t.trim().replace(/\s{2,}/g," ")}function Vt(e){if(/%[0-9A-Fa-f]{2}/.test(e))return e;try{return encodeURI(e)}catch{return e}}function ya(e,t){if(!e||/^(data|blob|about|#)/i.test(e.trim()))return e;try{let r=t||typeof document<"u"&&(document.baseURI||document.location?.href)||"http://localhost/";return new URL(e,r).href}catch{return e}}function ba(e="[snapDOM]",{ttlMs:t=5*6e4,maxEntries:r=12}={}){let n=new Map,o=0;function i(a,l,c){if(o>=r)return;let s=Date.now();(n.get(l)||0)>s||(n.set(l,s+t),o++,a==="warn"&&console&&console.warn?console.warn(`${e} ${c}`):console&&console.error&&console.error(`${e} ${c}`))}return{warnOnce(a,l){i("warn",a,l)},errorOnce(a,l){i("error",a,l)},reset(){n.clear(),o=0}}}function wa(e){return/^data:|^blob:|^about:blank$/i.test(e)}function Sa(e,t){try{let r=typeof location<"u"&&location.href?location.href:"http://localhost/",n=t.includes("{url}")?t.split("{url}")[0]:t,o=new URL(n||".",r),i=new URL(e,r);if(i.origin===o.origin)return!0;let a=i.searchParams;if(a&&(a.has("url")||a.has("target")))return!0}catch{}return!1}function Ca(e,t){if(!t||wa(e)||Sa(e,t))return!1;try{let r=typeof location<"u"&&location.href?location.href:"http://localhost/",n=new URL(e,r);return typeof location<"u"?n.origin!==location.origin:!0}catch{return!!t}}function va(e,t){if(!t)return e;if(t.includes("{url}"))return t.replace("{urlRaw}",Vt(e)).replace("{url}",encodeURIComponent(e));if(/[?&]url=?$/.test(t))return`${t}${encodeURIComponent(e)}`;if(t.endsWith("?"))return`${t}url=${encodeURIComponent(e)}`;if(t.endsWith("/"))return`${t}${Vt(e)}`;let r=t.includes("?")?"&":"?";return`${t}${r}url=${encodeURIComponent(e)}`}function Tn(e){return new Promise((t,r)=>{let n=new FileReader;n.onload=()=>t(String(n.result||"")),n.onerror=()=>r(new Error("read_failed")),n.readAsDataURL(e)})}function Ia(e,t){return[t.as||"blob",t.timeout??3e3,t.useProxy||"",t.errorTTL??8e3,e].join("|")}async function be(e,t={}){let r=t.as??"blob",n=t.timeout??3e3,o=t.useProxy||"",i=t.errorTTL??8e3,a=t.headers||{},l=!!t.silent;if(/^data:/i.test(e))try{if(r==="text")return{ok:!0,data:String(e),status:200,url:e,fromCache:!1};if(r==="dataURL")return{ok:!0,data:String(e),status:200,url:e,fromCache:!1,mime:String(e).slice(5).split(";")[0]||""};let[,h="",y=""]=String(e).match(/^data:([^,]*),(.*)$/)||[],b=/;base64/i.test(h)?atob(y):decodeURIComponent(y),w=new Uint8Array([...b].map(I=>I.charCodeAt(0))),S=new Blob([w],{type:(h||"").split(";")[0]||""});return{ok:!0,data:S,status:200,url:e,fromCache:!1,mime:S.type||""}}catch{return{ok:!1,data:null,status:0,url:e,fromCache:!1,reason:"special_url_error"}}if(/^blob:/i.test(e))try{let h=await fetch(e);if(!h.ok)return{ok:!1,data:null,status:h.status,url:e,fromCache:!1,reason:"http_error"};let y=await h.blob(),b=y.type||h.headers.get("content-type")||"";return r==="dataURL"?{ok:!0,data:await Tn(y),status:h.status,url:e,fromCache:!1,mime:b}:r==="text"?{ok:!0,data:await y.text(),status:h.status,url:e,fromCache:!1,mime:b}:{ok:!0,data:y,status:h.status,url:e,fromCache:!1,mime:b}}catch{return{ok:!1,data:null,status:0,url:e,fromCache:!1,reason:"network"}}if(/^about:blank$/i.test(e))return r==="dataURL"?{ok:!0,data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg==",status:200,url:e,fromCache:!1,mime:"image/png"}:{ok:!0,data:r==="text"?"":new Blob([]),status:200,url:e,fromCache:!1};let c=Ia(e,{as:r,timeout:n,useProxy:o,errorTTL:i}),s=bt.get(c);if(s&&s.until>Date.now())return{...s.result,fromCache:!0};s&&bt.delete(c);let u=_t.get(c);if(u)return u;let d=Ca(e,o)?va(e,o):e,f=t.credentials;if(!f)try{let h=typeof location<"u"&&location.href?location.href:"http://localhost/",y=new URL(e,h);f=typeof location<"u"&&y.origin===location.origin?"include":"omit"}catch{f="omit"}let m=new AbortController,g=setTimeout(()=>m.abort("timeout"),n),p=(async()=>{try{let h=await fetch(d,{signal:m.signal,credentials:f,headers:a});if(!h.ok){let w={ok:!1,data:null,status:h.status,url:d,fromCache:!1,reason:"http_error"};if(i>0&&bt.set(c,{until:Date.now()+i,result:w}),!l){let S=`${h.status} ${h.statusText||""}`.trim();Lr.warnOnce(`http:${h.status}:${r}:${new URL(e,location?.href??"http://localhost/").origin}`,`HTTP error ${S} while fetching ${r} ${e}`)}return t.onError&&t.onError(w),w}if(r==="text")return{ok:!0,data:await h.text(),status:h.status,url:d,fromCache:!1};let y=await h.blob(),b=y.type||h.headers.get("content-type")||"";return r==="dataURL"?{ok:!0,data:await Tn(y),status:h.status,url:d,fromCache:!1,mime:b}:{ok:!0,data:y,status:h.status,url:d,fromCache:!1,mime:b}}catch(h){let y=h&&typeof h=="object"&&"name"in h&&h.name==="AbortError"?String(h.message||"").includes("timeout")?"timeout":"abort":"network",b={ok:!1,data:null,status:0,url:d,fromCache:!1,reason:y};if(!/^blob:/i.test(e)&&i>0&&bt.set(c,{until:Date.now()+i,result:b}),!l){let w=`${y}:${r}:${new URL(e,location?.href??"http://localhost/").origin}`,S=y==="timeout"?`Timeout after ${n}ms. Consider increasing timeout or using a proxy for ${e}`:y==="abort"?`Request aborted while fetching ${r} ${e}`:`Network/CORS issue while fetching ${r} ${e}. A proxy may be required`;Lr.errorOnce(w,S)}return t.onError&&t.onError(b),b}finally{clearTimeout(g),_t.delete(c)}})();return _t.set(c,p),p}async function zr(e,t={}){if(/^((repeating-)?(linear|radial|conic)-gradient)\(/i.test(e)||e.trim()==="none")return e;let r=Gr(e);if(!r)return e;let n=ya(r),o=Vt(n);if(x.background.has(o)){let i=x.background.get(o);return i?`url("${i}")`:"none"}try{let i=await be(o,{as:"dataURL",useProxy:t.useProxy});return i.ok?(x.background.set(o,i.data),`url("${i.data}")`):(x.background.set(o,null),"none")}catch{return x.background.set(o,null),"none"}}function Aa(){for(let e of eo){let t=String(e).toLowerCase();Zr.has(t)||jt.has(t)||Qn(t)}}function Qn(e){if(e=String(e).toLowerCase(),jt.has(e)){let i={};return x.defaultStyle.set(e,i),i}if(x.defaultStyle.has(e))return x.defaultStyle.get(e);let t=document.getElementById("snapdom-sandbox");t||(t=document.createElement("div"),t.id="snapdom-sandbox",t.setAttribute("data-snapdom-sandbox","true"),t.setAttribute("aria-hidden","true"),t.style.position="absolute",t.style.left="-9999px",t.style.top="-9999px",t.style.width="0px",t.style.height="0px",t.style.overflow="hidden",document.body.appendChild(t));let r=document.createElement(e);r.style.all="initial",t.appendChild(r);let n=getComputedStyle(r),o={};for(let i of n){if(jr(i))continue;let a=n.getPropertyValue(i);o[i]=a}return t.removeChild(r),x.defaultStyle.set(e,o),o}function jr(e){let t=String(e).toLowerCase();return!!(no.has(t)||ro.test(t)||to.test(t))}function Or(e,t){if(t=String(t||"").toLowerCase(),jt.has(t))return"";let r=[],n=Qn(t),o=(e.display||"").toLowerCase()==="inline"||new Set(["span","small","em","strong","b","i","u","s","code","cite","mark","sub","sup"]).has(t);for(let[i,a]of Object.entries(e)){if(jr(i)||o&&(i==="width"||i==="min-width"||i==="max-width"))continue;let l=n[i];a&&a!==l&&r.push(`${i}:${a}`)}return r.sort(),r.join(";")}function xa(e){let t=new Set;return e.nodeType!==Node.ELEMENT_NODE&&e.nodeType!==Node.DOCUMENT_FRAGMENT_NODE?[]:(e.tagName&&t.add(e.tagName.toLowerCase()),typeof e.querySelectorAll=="function"&&e.querySelectorAll("*").forEach(r=>t.add(r.tagName.toLowerCase())),Array.from(t))}function Ma(e){let t=new Map;for(let n of e){let o=x.defaultStyle.get(n);if(!o)continue;let i=Object.entries(o).map(([a,l])=>`${a}:${l};`).sort().join("");i&&(t.has(i)||t.set(i,[]),t.get(i).push(n))}let r="";for(let[n,o]of t.entries())r+=`${o.join(",")} { ${n} } `;return r}function Ta(e){let t=Array.from(new Set(e.values())).filter(Boolean).sort(),r=new Map,n=1;for(let o of t)r.set(o,`c${n++}`);return r}function ka(e){try{let t=e?.ownerDocument;if(!t)return typeof window<"u"?window:null;let r=t.defaultView;if(r&&typeof r.getComputedStyle=="function")return r;if(typeof window<"u"&&window.frames)for(let n=0;n{let i={length:0,getPropertyValue:()=>"",item:()=>""};return i[Symbol.iterator]=function*(){},i};if(!(e instanceof Element)){let i=typeof window<"u"?window:null;if(i&&typeof i.getComputedStyle=="function")try{return i.getComputedStyle(e,t)||r()}catch{return r()}return r()}let n=x.computedStyle.get(e);n||(n=new Map,x.computedStyle.set(e,n));let o=n.get(t);if(!o){let i=ka(e),a=null;try{a=i&&typeof i.getComputedStyle=="function"?i.getComputedStyle(e,t):null}catch{}if(!a&&typeof window<"u"&&typeof window.getComputedStyle=="function")try{e.ownerDocument===document&&(a=window.getComputedStyle(e,t))}catch{}o=a||r(),n.set(t,o)}return o}function kn(e){let t={};for(let r of e)t[r]=e.getPropertyValue(r);return t}function Dr(e){let t=[],r=0,n=0;for(let o=0;o"u")return!1;if(navigator.userAgentData)return navigator.userAgentData.platform==="iOS";let e=navigator.userAgent||"",t=/iPhone|iPad|iPod/.test(e),r=navigator.maxTouchPoints>2&&/Macintosh/.test(e);return t||r}function xe(){if(typeof navigator>"u")return!1;let e=navigator.userAgent||"",t=e.toLowerCase(),r=t.includes("safari")&&!t.includes("chrome")&&!t.includes("crios")&&!t.includes("fxios")&&!t.includes("android"),n=/applewebkit/i.test(e),o=/mobile/i.test(e),i=!/safari/i.test(e),a=n&&o&&i,l=/(micromessenger|wxwork|wecom|windowswechat|macwechat)/i.test(e),c=/(baiduboxapp|baidubrowser|baidusearch|baiduboxlite)/i.test(t),s=/ipad|iphone|ipod/.test(t)&&n;return r||a||l||c||s}function Ra(){if(typeof navigator>"u")return!1;let e=(navigator.userAgent||"").toLowerCase();return e.includes("firefox")||e.includes("fxios")}function X(e,t,r){let n=e&&typeof e=="object"&&(e.options||e);n&&n.debug&&(r!==void 0?console.warn("[snapdom]",t,r):console.warn("[snapdom]",t))}function La(e){return typeof e=="string"&&/^data:image\/svg\+xml/i.test(e)}function Oa(e){let t=e.indexOf(",");return t>=0?decodeURIComponent(e.slice(t+1)):""}function Da(e){return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`}function Fa(e){let t=[],r="",n=0;for(let o=0;oo.trim()).filter(Boolean)}function Pa(e){let t=[],r="",n=0;for(let i=0;i`${l}:${c}`).join(";")}function _a(e){return e.replace(/([^{}]+)\{([^}]*)\}/g,(t,r,n)=>`${r}{${so(n)}}`)}function Wa(e){return e=e.replace(/]*>([\s\S]*?)<\/style>/gi,(t,r)=>t.replace(r,_a(r))),e=e.replace(/style=(['"])([\s\S]*?)\1/gi,(t,r,n)=>`style=${r}${so(n)}${r}`),e}function Ba(e){if(!xe()||!La(e))return e;try{let t=Oa(e),r=Wa(t);return Da(r)}catch{return e}}async function Zt(e,t){let{width:r,height:n,scale:o=1,dpr:i=1,meta:a={},backgroundColor:l}=t;e=Ba(e);let c=new Image;c.loading="eager",c.decoding="sync",c.crossOrigin="anonymous",c.src=e,await c.decode();let s=c.naturalWidth,u=c.naturalHeight,d=Number.isFinite(a.w0)?a.w0:s,f=Number.isFinite(a.h0)?a.h0:u,m,g,p=Number.isFinite(r),h=Number.isFinite(n);if(p&&h)m=Math.max(1,r),g=Math.max(1,n);else if(p){let w=r/Math.max(1,d);m=r,g=f*w}else if(h){let w=n/Math.max(1,f);g=n,m=d*w}else m=s,g=u;m=m*o,g=g*o;let y=document.createElement("canvas");y.width=m*i,y.height=g*i,y.style.width=`${m}px`,y.style.height=`${g}px`;let b=y.getContext("2d");return i!==1&&b.scale(i,i),l&&(b.save(),b.fillStyle=l,b.fillRect(0,0,m,g),b.restore()),b.drawImage(c,0,0,m,g),y}async function lo(e,t){let r=await Zt(e,t),n=new Image;return n.src=r.toDataURL(`image/${t.format}`,t.quality),await n.decode(),n.style.width=`${r.width/t.dpr}px`,n.style.height=`${r.height/t.dpr}px`,n}async function Nn(e,t){let{scale:r=1,width:n,height:o,meta:i={}}=t,a=Number.isFinite(n),l=Number.isFinite(o),c=Number.isFinite(r)&&r!==1||a||l;if(xe()&&c)return await lo(e,{...t,format:"png",quality:1,meta:i});let s=new Image;if(s.decoding="sync",s.loading="eager",s.src=e,await s.decode(),a&&l)s.style.width=`${n}px`,s.style.height=`${o}px`;else if(a){let u=Number.isFinite(i.w0)?i.w0:s.naturalWidth,d=Number.isFinite(i.h0)?i.h0:s.naturalHeight,f=n/Math.max(1,u);s.style.width=`${n}px`,s.style.height=`${Math.round(d*f)}px`}else if(l){let u=Number.isFinite(i.w0)?i.w0:s.naturalWidth,d=Number.isFinite(i.h0)?i.h0:s.naturalHeight,f=o/Math.max(1,d);s.style.height=`${o}px`,s.style.width=`${Math.round(u*f)}px`}else{let u=Math.round(s.naturalWidth*r),d=Math.round(s.naturalHeight*r);if(s.style.width=`${u}px`,s.style.height=`${d}px`,typeof e=="string"&&e.startsWith("data:image/svg+xml"))try{let f=decodeURIComponent(e.split(",")[1]).replace(/width="[^"]*"/,`width="${u}"`).replace(/height="[^"]*"/,`height="${d}"`);e=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(f)}`,s.src=e}catch(f){X(t,"SVG width/height patch in toImg failed",f)}}return s}async function uo(e,t){let r=t.type;if(r==="svg"){let o=decodeURIComponent(e.split(",")[1]);return new Blob([o],{type:"image/svg+xml"})}let n=await Zt(e,t);return new Promise(o=>n.toBlob(i=>o(i),`image/${r}`,t.quality))}async function Ln(e,t){let r=new File([e],t,{type:e.type});if(!navigator.canShare?.({files:[r]}))return!1;try{await navigator.share({files:[r],title:t})}catch(n){if(n.name!=="AbortError")return!1}return!0}async function $a(e,t){let r=new Set(["png","jpeg","jpg","webp","svg"]),n=(t?.type||"").toLowerCase(),o=r.has(n)?n:"",i=(t?.format||o||"").toLowerCase(),a=i==="jpg"?"jpeg":i||"png",l=t?.filename||`snapdom.${a}`,c={...t||{},format:a,type:a};c.dpr=1;let s=Na();if(a==="svg"){let f=await uo(e,{...c,type:"svg"});if(s&&await Ln(f,l))return;let m=URL.createObjectURL(f),g=document.createElement("a");g.href=m,g.download=l,document.body.appendChild(g),g.click(),URL.revokeObjectURL(m),g.remove();return}let u=await Zt(e,c);if(s){let f=`image/${a}`,m=await new Promise(g=>u.toBlob(g,f,t?.quality));if(m&&await Ln(m,l))return}let d=document.createElement("a");d.href=u.toDataURL(`image/${a}`,t?.quality),d.download=l,document.body.appendChild(d),d.click(),d.remove()}function wt(){Pr++,Ct.size>Ua&&Ct.clear()}function Va(e=document.documentElement){if(!Dn){Dn=!0;try{new MutationObserver(()=>wt()).observe(e,{subtree:!0,childList:!0,characterData:!0,attributes:!0})}catch{}try{new MutationObserver(()=>wt()).observe(document.head,{subtree:!0,childList:!0,characterData:!0,attributes:!0})}catch{}try{let t=document.fonts;t&&(t.addEventListener?.("loadingdone",wt),t.ready?.then(()=>wt()).catch(()=>{}))}catch{}}}function Ga(e,t={}){let r={},n=e.getPropertyValue("visibility"),o=t.excludeStyleProps;for(let d=0;dr[0]n[0]?1:0).map(([r,n])=>`${r}:${n}`).join(";"),Fn.set(e,t),t)}function ja(e,t=null,r={}){let n=On.get(e);if(n&&n.epoch===Pr)return n.snapshot;let o=t||getComputedStyle(e),i=Ga(o,r);return Qa(e,o,i),On.set(e,{epoch:Pr,snapshot:i}),i}function Za(e,t){return e&&e.session&&e.persist?e:e&&(e.styleMap||e.styleCache||e.nodeMap)?{session:e,persist:{snapshotKeyCache:Ct,defaultStyle:x.defaultStyle,baseStyle:x.baseStyle,image:x.image,resource:x.resource,background:x.background,font:x.font},options:t||{}}:{session:x.session,persist:{snapshotKeyCache:Ct,defaultStyle:x.defaultStyle,baseStyle:x.baseStyle,image:x.image,resource:x.resource,background:x.background,font:x.font},options:e||t||{}}}function Ya(e,t,r){if(!(!e.style||e.style.length===0))for(let n=0;n0||(parseFloat(e.borderBottomWidth)||0)>0||(parseFloat(e.paddingTop)||0)>0||(parseFloat(e.paddingBottom)||0)>0?!0:(e.overflowBlock||e.overflowY||"visible")!=="visible"}function qa(e){let t=e.parentElement;if(!t)return!1;let r=getComputedStyle(t).display||"";return r.includes("flex")||r.includes("grid")}function Ja(e,t){if(e.textContent&&/\S/.test(e.textContent))return!0;let r=e.firstElementChild,n=e.lastElementChild;if(r&&r.tagName==="BR"||n&&n.tagName==="BR")return!0;let o=e.scrollHeight;if(o===0)return!1;let i=parseFloat(t.paddingTop)||0,a=parseFloat(t.paddingBottom)||0;return o>i+a}function Qa(e,t,r){if(e instanceof HTMLElement&&e.style&&e.style.height)return;let n=e.tagName&&e.tagName.toLowerCase();if(!n||!["div","section","article","main","aside","header","footer","nav"].includes(n))return;let o=parseFloat(t.height);if(Number.isFinite(o)&&e.scrollHeight>0&&Math.abs(o-e.scrollHeight)>2||t.aspectRatio&&t.aspectRatio!=="none"&&t.aspectRatio!=="auto")return;let i=t.display||"";if(i.includes("flex")||i.includes("grid")||Ka(e))return;let a=t.position;if(a==="absolute"||a==="fixed"||a==="sticky"||t.transform!=="none"||Xa(t)||qa(e))return;let l=t.overflowX||t.overflow||"visible",c=t.overflowY||t.overflow||"visible";if(l!=="visible"||c!=="visible")return;let s=t.clip;s&&s!=="auto"&&s!=="rect(auto, auto, auto, auto)"||t.visibility==="hidden"||t.opacity==="0"||Ja(e,t)&&(delete r.height,delete r["block-size"])}function es(e,t){let r=t+"::"+e.toLowerCase(),n=Pn.get(r);if(n)return n;let o=document,i=t==="http://www.w3.org/2000/svg"?o.createElementNS(t,e):o.createElement(e),a=o.createElement("div");a.style.cssText="position:absolute;left:-99999px;top:-99999px;contain:strict;display:block;",a.appendChild(i),o.documentElement.appendChild(a);let l=getComputedStyle(i),c={};for(let s of po)c[s]=l.getPropertyValue(s)||"";return a.remove(),Pn.set(r,c),c}function ts(e,t){if(!(e instanceof Element)||!(t instanceof Element))return;let r=e.getAttribute?.("style"),n=!!(r&&r.includes("var("));if(!n&&e.attributes?.length){let i=e.attributes;for(let a=0;anew Promise(o=>{function i(){tt(a=>{!(a&&typeof a.timeRemaining=="function")||a.timeRemaining()>0?t(n,o):i()},{fast:r})}i()})))}function rs(e){return e=e.trim(),!e||/:not\(\s*\[data-sd-slotted\]\s*\)\s*$/.test(e)?e:`${e}:not([data-sd-slotted])`}function ns(e,t,r=!0){return e.split(",").map(n=>n.trim()).filter(Boolean).map(n=>{if(n.startsWith(":where(")||n.startsWith("@"))return n;let o=r?rs(n):n;return`:where(${t} ${o})`}).join(", ")}function os(e,t){return e?(e=e.replace(/:host\(([^)]+)\)/g,(r,n)=>`:where(${t}:is(${n.trim()}))`),e=e.replace(/:host\b/g,`:where(${t})`),e=e.replace(/:host-context\(([^)]+)\)/g,(r,n)=>`:where(:where(${n.trim()}) ${t})`),e=e.replace(/::slotted\(([^)]+)\)/g,(r,n)=>`:where(${t} ${n.trim()})`),e=e.replace(/(^|})(\s*)([^@}{]+){/g,(r,n,o,i)=>{let a=ns(i,t,!0);return`${n}${o}${a}{`}),e):""}function is(e){return e.shadowScopeSeq=(e.shadowScopeSeq||0)+1,`s${e.shadowScopeSeq}`}function as(e){let t="";try{e.querySelectorAll("style").forEach(n=>{t+=(n.textContent||"")+` `});let r=e.adoptedStyleSheets||[];for(let n of r)try{if(n&&n.cssRules)for(let o of n.cssRules)t+=o.cssText+` `}catch{}}catch{}return t}function ss(e,t,r){if(!t)return;let n=document.createElement("style");n.setAttribute("data-sd",r),n.textContent=t,e.insertBefore(n,e.firstChild||null)}function ls(e,t){try{let r=e.currentSrc||e.src||"";if(!r)return;t.setAttribute("src",r),t.removeAttribute("srcset"),t.removeAttribute("sizes"),t.loading="eager",t.decoding="sync"}catch{}}function cs(e){let t=new Set;if(!e)return t;let r=/var\(\s*(--[A-Za-z0-9_-]+)\b/g,n;for(;n=r.exec(e);)t.add(n[1]);return t}function us(e,t){try{let r=getComputedStyle(e).getPropertyValue(t).trim();if(r)return r}catch{}try{let r=getComputedStyle(document.documentElement).getPropertyValue(t).trim();if(r)return r}catch{}return""}function ds(e,t,r){let n=[];for(let o of t){let i=us(e,o);i&&n.push(`${o}: ${i};`)}return n.length?`${r}{${n.join("")}} `:""}function fs(e){e&&(e.nodeType===Node.ELEMENT_NODE&&e.setAttribute("data-sd-slotted",""),e.querySelectorAll&&e.querySelectorAll("*").forEach(t=>t.setAttribute("data-sd-slotted","")))}async function ms(e,t=3){let r=()=>{try{return e.contentDocument||e.contentWindow?.document||null}catch{return null}},n=r(),o=0;for(;osetTimeout(i,0)),n=r(),o++;return n&&(n.body||n.documentElement)?n:null}function ps(e){let t=e.getBoundingClientRect(),r=0,n=0,o=0,i=0;try{let c=getComputedStyle(e);r=parseFloat(c.borderLeftWidth)||0,n=parseFloat(c.borderRightWidth)||0,o=parseFloat(c.borderTopWidth)||0,i=parseFloat(c.borderBottomWidth)||0}catch{}let a=Math.max(0,Math.round(t.width-(r+n))),l=Math.max(0,Math.round(t.height-(o+i)));return{contentWidth:a,contentHeight:l,rect:t}}function Ee(e){let t=0,r=0;if(e.offsetWidth>0&&(t=e.offsetWidth),e.offsetHeight>0&&(r=e.offsetHeight),t===0||r===0)try{let n=getComputedStyle(e);if(t===0){let o=parseFloat(n.width);!isNaN(o)&&o>0&&(t=o)}if(r===0){let o=parseFloat(n.height);!isNaN(o)&&o>0&&(r=o)}}catch{}if(t===0||r===0)try{if(t===0){let n=parseFloat(e.getAttribute("width"));!isNaN(n)&&n>0&&(t=n)}if(r===0){let n=parseFloat(e.getAttribute("height"));!isNaN(n)&&n>0&&(r=n)}}catch{}if((t===0||r===0)&&(e.naturalWidth||e.naturalHeight))try{t===0&&e.naturalWidth>0&&(t=e.naturalWidth),r===0&&e.naturalHeight>0&&(r=e.naturalHeight)}catch{}return{width:t,height:r}}function hs(e,t,r){let n=e.createElement("style");return n.setAttribute("data-sd-iframe-pin",""),n.textContent=`html, body {margin: 0 !important;padding: 0 !important;width: ${t}px !important;height: ${r}px !important;min-width: ${t}px !important;min-height: ${r}px !important;box-sizing: border-box !important;overflow: hidden !important;background-clip: border-box !important;}`,(e.head||e.documentElement).appendChild(n),()=>{try{n.remove()}catch{}}}async function gs(e,t,r){let n=await ms(e,3);if(!n)throw new Error("iframe document not accessible/ready");let{contentWidth:o,contentHeight:i,rect:a}=ps(e),l=r?.snap;if(!l&&typeof window<"u"&&window.snapdom&&(l=window.snapdom),!l||typeof l.toPng!="function")throw new Error("[snapdom] iframe capture requires snapdom.toPng. Use snapdom(el) or pass options.snap. With ESM, assign window.snapdom = snapdom after import if using iframes.");let c={...r,scale:1},s=hs(n,o,i),u;try{u=await l.toPng(n.documentElement,c)}finally{s()}u.style.display="block",u.style.width=`${o}px`,u.style.height=`${i}px`;let d=document.createElement("div");return t.nodeMap.set(d,e),ze(e,d,t,r),d.style.overflow="hidden",d.style.display="block",d.style.width||(d.style.width=`${Math.round(a.width)}px`),d.style.height||(d.style.height=`${Math.round(a.height)}px`),d.appendChild(u),d}function ys(e){let{width:t,height:r}=Ee(e),n=e.getBoundingClientRect(),o;try{o=window.getComputedStyle(e)}catch{}let i=o?parseFloat(o.width):NaN,a=o?parseFloat(o.height):NaN,l=Math.round(t||n.width||0),c=Math.round(r||n.height||0),s=Number.isFinite(i)&&i>0?Math.round(i):Math.max(12,l||16),u=Number.isFinite(a)&&a>0?Math.round(a):Math.max(12,c||16),d=(e.type||"text").toLowerCase()==="checkbox",f=!!e.checked,m=!!e.indeterminate,g=Math.max(Math.min(s,u),12),p="middle";try{o&&o.verticalAlign&&(p=o.verticalAlign)}catch{}let h=document.createElement("div");h.setAttribute("data-snapdom-input-replacement",e.type||"checkbox"),h.style.cssText=`display:inline-block;width:${g}px;height:${g}px;vertical-align:${p};flex-shrink:0;line-height:0;`;let y=document.createElementNS("http://www.w3.org/2000/svg","svg");y.setAttribute("width",String(g)),y.setAttribute("height",String(g)),y.setAttribute("viewBox",`0 0 ${g} ${g}`),h.appendChild(y);function b(){let w="#0a6ed1";try{o&&(w=o.accentColor||o.color||w)}catch{}let S=2,I=S/2,A=g-S;if(y.innerHTML="",d){let C=document.createElementNS("http://www.w3.org/2000/svg","rect");if(C.setAttribute("x",String(I)),C.setAttribute("y",String(I)),C.setAttribute("width",String(A)),C.setAttribute("height",String(A)),C.setAttribute("rx","2"),C.setAttribute("ry","2"),C.setAttribute("fill",f?w:"none"),C.setAttribute("stroke",w),C.setAttribute("stroke-width",String(S)),y.appendChild(C),f){let E=document.createElementNS("http://www.w3.org/2000/svg","path");E.setAttribute("d",`M ${I+2} ${g/2} L ${g/2-1} ${g-I-2} L ${g-I-2} ${I+2}`),E.setAttribute("stroke","white"),E.setAttribute("stroke-width",String(Math.max(1.5,S))),E.setAttribute("fill","none"),E.setAttribute("stroke-linecap","round"),E.setAttribute("stroke-linejoin","round"),y.appendChild(E)}else if(m){let E=document.createElementNS("http://www.w3.org/2000/svg","rect"),T=Math.max(6,A-4);E.setAttribute("x",String((g-T)/2)),E.setAttribute("y",String((g-S)/2)),E.setAttribute("width",String(T)),E.setAttribute("height",String(S)),E.setAttribute("fill",w),E.setAttribute("rx","1"),y.appendChild(E)}}else{let C=document.createElementNS("http://www.w3.org/2000/svg","circle");if(C.setAttribute("cx",String(g/2)),C.setAttribute("cy",String(g/2)),C.setAttribute("r",String((g-S)/2)),C.setAttribute("fill",f?w:"none"),C.setAttribute("stroke",w),C.setAttribute("stroke-width",String(S)),y.appendChild(C),f){let E=document.createElementNS("http://www.w3.org/2000/svg","circle"),T=Math.max(2,(g-S*2)*.35);E.setAttribute("cx",String(g/2)),E.setAttribute("cy",String(g/2)),E.setAttribute("r",String(T)),E.setAttribute("fill","white"),y.appendChild(E)}}h.style.setProperty("width",`${g}px`,"important"),h.style.setProperty("height",`${g}px`,"important"),h.style.setProperty("min-width",`${g}px`,"important"),h.style.setProperty("min-height",`${g}px`,"important")}return b(),{el:h,applyVisual:b}}async function St(e){if(x.resource?.has(e))return x.resource.get(e);if(yt.has(e))return yt.get(e);let t=(async()=>{let r=await be(e,{as:"dataURL",silent:!0});if(!r.ok||typeof r.data!="string")throw new Error(`[snapDOM] Failed to read blob URL: ${e}`);return x.resource?.set(e,r.data),r.data})();yt.set(e,t);try{let r=await t;return yt.set(e,r),r}catch(r){throw yt.delete(e),r}}async function _n(e){if(!e||e.indexOf("blob:")===-1)return e;let t=Array.from(new Set(e.match(bs)||[]));if(t.length===0)return e;let r=e;for(let n of t)try{let o=await St(n);r=r.split(n).join(o)}catch{}return r}function Pt(e){return typeof e=="string"&&e.startsWith("blob:")}function ws(e){return(e||"").split(",").map(t=>t.trim()).filter(Boolean).map(t=>{let r=t.match(/^(\S+)(\s+.+)?$/);return r?{url:r[1],desc:r[2]||""}:null}).filter(Boolean)}function Ss(e){return e.map(t=>t.desc?`${t.url} ${t.desc.trim()}`:t.url).join(", ")}async function Cs(e,t=null){if(!e)return;let r=t,n=e.querySelectorAll?e.querySelectorAll("img"):[];for(let c of n)try{let s=c.getAttribute("src")||c.currentSrc||"";if(Pt(s)){let d=await St(s);c.setAttribute("src",d)}let u=c.getAttribute("srcset");if(u&&u.includes("blob:")){let d=ws(u),f=!1;for(let m of d)if(Pt(m.url))try{m.url=await St(m.url),f=!0}catch(g){X(r,"blobUrlToDataUrl for srcset item failed",g)}f&&c.setAttribute("srcset",Ss(d))}}catch(s){X(r,"resolveBlobUrls for img failed",s)}let o=e.querySelectorAll?e.querySelectorAll("image"):[];for(let c of o)try{let s="http://www.w3.org/1999/xlink",u=c.getAttribute("href")||c.getAttributeNS?.(s,"href");if(Pt(u)){let d=await St(u);c.setAttribute("href",d),c.removeAttributeNS?.(s,"href")}}catch(s){X(r,"resolveBlobUrls for SVG image href failed",s)}let i=e.querySelectorAll?e.querySelectorAll("[style*='blob:']"):[];for(let c of i)try{let s=c.getAttribute("style");if(s&&s.includes("blob:")){let u=await _n(s);c.setAttribute("style",u)}}catch(s){X(r,"replaceBlobUrls in inline style failed",s)}let a=e.querySelectorAll?e.querySelectorAll("style"):[];for(let c of a)try{let s=c.textContent||"";s.includes("blob:")&&(c.textContent=await _n(s))}catch(s){X(r,"replaceBlobUrls in style tag failed",s)}let l=["poster"];for(let c of l){let s=e.querySelectorAll?e.querySelectorAll(`[${c}^='blob:']`):[];for(let u of s)try{let d=u.getAttribute(c);Pt(d)&&u.setAttribute(c,await St(d))}catch(d){X(r,`resolveBlobUrls for ${c} failed`,d)}}}async function $t(e,t,r){if(!e)throw new Error("Invalid node");let n=new Set,o=null,i=null;if(e.nodeType===Node.ELEMENT_NODE){let u=(e.localName||e.tagName||"").toLowerCase();if(e.id==="snapdom-sandbox"||e.hasAttribute("data-snapdom-sandbox")||Zr.has(u))return null;if(u==="foreignobject"&&e.parentElement?.closest?.("foreignObject"))return X(t,"Nested skipped (SVG spec limitation \u2014 not rendered by browsers)"),null}if(e.nodeType===Node.TEXT_NODE||e.nodeType!==Node.ELEMENT_NODE)return e.cloneNode(!0);if(e.getAttribute("data-capture")==="exclude"){if(r.excludeMode==="hide"){let u=document.createElement("div"),{width:d,height:f}=Ee(e),m=d||e.getBoundingClientRect().width||0,g=f||e.getBoundingClientRect().height||0;return u.style.cssText=`display:inline-block;width:${m}px;height:${g}px;visibility:hidden;`,u}else if(r.excludeMode==="remove")return null}if(r.exclude&&Array.isArray(r.exclude))for(let u of r.exclude)try{if(e.matches?.(u)){if(r.excludeMode==="hide"){let d=document.createElement("div"),{width:f,height:m}=Ee(e),g=f||e.getBoundingClientRect().width||0,p=m||e.getBoundingClientRect().height||0;return d.style.cssText=`display:inline-block;width:${g}px;height:${p}px;visibility:hidden;`,d}else if(r.excludeMode==="remove")return null}}catch(d){console.warn(`Invalid selector in exclude option: ${u}`,d)}if(typeof r.filter=="function")try{if(!r.filter(e)){if(r.filterMode==="hide"){let u=document.createElement("div"),{width:d,height:f}=Ee(e),m=d||e.getBoundingClientRect().width||0,g=f||e.getBoundingClientRect().height||0;return u.style.cssText=`display:inline-block;width:${m}px;height:${g}px;visibility:hidden;`,u}else if(r.filterMode==="remove")return null}}catch(u){console.warn("Error in filter function:",u)}if(e.tagName==="IFRAME"){let u=!1;try{u=!!(e.contentDocument||e.contentWindow?.document)}catch(d){X(t,"iframe same-origin probe failed",d)}if(u)try{return await gs(e,t,r)}catch(d){console.warn("[SnapDOM] iframe rasterization failed, fallback:",d)}if(u||console.warn("[snapdom] cross-origin